﻿using MediatR;
using Traceability.App.Api.Read.Application.Command.Trace;
using Traceability.App.Domain.新文件夹;
using Traceability.App.ErrorCode;
using Traceability.App.Intrastructure.Interface;

namespace Traceability.App.Api.Read.Application.Handler.Trace
{
    public class GetShopHandler : IRequestHandler<GetShopCommand, ApiResult<List<ShopModel>>>
    {
        private readonly IBaseRepository<ShopModel> shopRepo;

        public GetShopHandler(IBaseRepository<ShopModel> shopRepo)
        {
            this.shopRepo = shopRepo;
        }
        public Task<ApiResult<List<ShopModel>>> Handle(GetShopCommand request, CancellationToken cancellationToken)
        {
            var res = new ApiResult<List<ShopModel>>();
            var shop = shopRepo.GetAll();
            res.Message = "查询成功";
            res.Code = ApiEnum.Ok;
            res.Data = shop.ToList();
            return Task.FromResult(res);

        }
    }
}
